package spring.core.examples.java.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import spring.core.examples.xml.Publisher;
import spring.core.examples.xml.Subscriber;

/**
 * Demonstrate how to configure publisher and subscriber in Spring. Note that
 * publisher will be blocked until all subscribers are finished. Subscribers use
 * same transaction.
 */
@Configuration
@Profile("production")
public class PublishSubscribeConfiguration {

	/**
	 * Defines a publisher.
	 * 
	 * @return the publisher
	 */
	@Bean
	Publisher publisher() {
		return new Publisher();
	}

	/**
	 * Defines the first subscriber.
	 * 
	 * @return the subscriber
	 */
	@Bean
	Subscriber subscriper1() {
		return new Subscriber();
	}

	/**
	 * Defines the second subsriber.
	 * 
	 * @return the subscriber
	 */
	@Bean
	Subscriber subscriper2() {
		return new Subscriber();
	}

}
